<?php
class Default_Form_Regis extends Zend_Form{
    
    public function init(){
        
        $this->setName("default");
        $this->setAction('default/auth/regis');        
        
        $username = new Zend_Form_Element_Text('username');
        $username->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $username->setAttrib('class','form-control')->setAttrib('placeholder','Tên đăng nhập');
        $username->removeDecorator('dtddwrapper')->removeDecorator('HtmlTag')->removeDecorator('Label');
        
        $email = new Zend_Form_Element_Text('email');
        $email->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->addValidator('EmailAddress');
        $email->setAttrib('class','form-control')->setAttrib('placeholder','Email');        
        $email->removeDecorator('dtddwrapper')->removeDecorator('HtmlTag')->removeDecorator('Label');
        
        $password = new Zend_Form_Element_Password('password');
        $password->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $password ->setAttrib('class','form-control')->setAttrib('placeholder','Mật khẩu');        
        $password->removeDecorator('dtddwrapper')->removeDecorator('HtmlTag')->removeDecorator('Label');
        
        $fullname = new Zend_Form_Element_Text('fullname');
        $fullname->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $fullname->setAttrib('class','form-control')->setAttrib('placeholder','Họ tên');
        $fullname->removeDecorator('dtddwrapper')->removeDecorator('HtmlTag')->removeDecorator('Label');
            
        $mobile = new Zend_Form_Element_Text('mobile');
        $mobile->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $mobile->setAttrib('class','form-control')->setAttrib('placeholder','Di động');
        $mobile->removeDecorator('dtddwrapper')->removeDecorator('HtmlTag')->removeDecorator('Label');            
        
        $address = new Zend_Form_Element_Text('address');
        $address->addFilter('StripTags')->addFilter('StringTrim');
        $address->setAttrib('class','form-control')->setAttrib('placeholder','Địa chỉ');
        $address->removeDecorator('dtddwrapper')->removeDecorator('HtmlTag')->removeDecorator('Label');
            
        $captcha = new Zend_Form_Element_Captcha(  
            'captcha', // This is the name of the input field  
            array(
            'captcha' => array( // Here comes the magic...  
            // First the type...  
            'captcha' => 'Image',  
            // Length of the word...  
            'wordLen' => 6,              
            // Captcha timeout, 5 mins  
            'timeout' => 300,  
            // What font to use...  
            'font' => PUBLIC_PATH.'/captcha/arial.ttf',  
            // Where to put the image  
            'imgDir' => PUBLIC_PATH.'/captcha/',  
            // URL to the images  
            // This was bogus, here's how it should be... Sorry again :S  
            'imgUrl' =>  BASE_URL.'/captcha/',  
        )));
        $captcha->setAttrib('class','form-control')->setAttrib('placeholder','Mã xác thực');                
        $captcha->removeDecorator('dtddwrapper')->removeDecorator('HtmlTag')->removeDecorator('Label');                                                        
                
                                
        $sm=new Zend_Form_Element_Button('submit');
        $sm->setAttrib('type','submit');
        $sm->setLabel('Signup')
            ->removeDecorator('dtddwrapper');                                                                                 
        $this->setDecorators(array(
                               array('viewScript',
                               array('viewScript'=>'template/form_regis.phtml'),
                        )));    
        $this->addElements(array(
            $username, $email, $password, $fullname, $mobile, $address, $captcha,$sm
        ));                                                  
    }
}